package org.stwy.lease.quit;

import java.util.Date;

import javax.servlet.ServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rap.common.exception.ServiceException;
import com.rap.frame.web.ActionResultModel;
import com.rap.frame.web.BaseController;

/*
 * 退租 控制类
 */
/**
*版权信息 (c) RAP 保留所有权利.
*@author Rap.Codegen
*@Team RAP Team
*@Date 2015-4-19 22:11:54
*<p></p>
*
*@参与人：Rap.Codegen
*/

@Controller
@RequestMapping(value = "/lease/quit")
public class QuitController extends BaseController<QuitEntity> {

	public QuitController() {
		setResourceIdentity("stwy:lease:quit");
	}
	private QuitService getService(){
		return (QuitService)super.baseService;
	}

	@RequestMapping(method = RequestMethod.GET)
	public String view(Model model) {
		super.assertHasViewPermission();
		return "stwy/lease/quit/quit_main";
	}

	@RequestMapping(value = "/select")
	public String select(Model model, String callback) {
		model.addAttribute("callback", callback);
		return "stwy/lease/quit/quit_select";
	}
	@SuppressWarnings({ "rawtypes" })
	@RequestMapping(value = "/returnmoney")
	@ResponseBody
	public ActionResultModel returnmoney(ServletRequest request, Model model
			,Date returnDate,Double returnRent,Double returnDeposit,String remark,String[] pks) {
		ActionResultModel arm = new ActionResultModel();
		try {
			getService().doReturnMoney(pks, returnDate, remark,returnRent,returnDeposit);
			arm.setSuccess(true);
		} catch (ServiceException e) {
			e.printStackTrace();
			arm.setSuccess(false);
			arm.setMsg(e.getMessage());
		}catch (Exception e) {
			arm.setSuccess(false);
			arm.setMsg(e.getMessage());
			e.printStackTrace();
		}

		return arm;
	}
	
}
